Skip to content

IBM: evaluate a rotating body's ghost-cell wall velocity at the wall point - #2383

Merged
sbryngelson merged 3 commits into
MFlowCode:masterfrom
sbryngelson:ibm-wall-point-velocity
Nov 23, 2026
Merged

sbryngelson merged 3 commits into
MFlowCode:masterfrom
sbryngelson:ibm-wall-point-velocity

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Contribution Policy

All contributions are expected to demonstrate:

  • A clear understanding of the codebase
  • Alignment with product direction
  • Thoughtful reasoning behind changes
  • Evidence of real-world usage or hands-on experience with the problem

If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.

Summary

s_compute_ghost_point_velocity (src/simulation/m_ibm.fpp) evaluated a rotating body's wall velocity at the ghost point, f_wall_velocity(gp_patch_id, radial_vector) with radial_vector the centroid-to-ghost vector. The ghost point lies |levelset| inside the body, so a rotating circle imposed a wall speed Omega (R - |ls|) instead of Omega R: up to about dx/R of the wall speed (5 % at 20 cells/R), which is more than 100 % of the shear across one cell. s_compute_ghost_point_pressure already used the wall point r_w = radial_vector + |ls| n.

The fix factors that wall point into f_wall_point (shared by the pressure routine, so no duplicated construction) and evaluates the body's velocity there once, for both the no-slip and slip branches. It has no per-body or per-step global work, assigns every private unconditionally, and follows the existing GPU_ROUTINE conventions. Translating-only and fixed bodies have a uniform wall velocity, so they are unchanged. This is a CFD-result change for rotating bodies only.

Separate observation, not part of this PR: the default no-slip ghost value on a static wall is first order (the wall sits about 0.7 cell inside); second order is the opt-in ib_wall_order = 2.

Verification

Taylor-Couette (examples/2D_ibm_taylor_couette of #2373: inner cylinder rotating, fixed outer STL ring at 2R, ideal gas, constant mu, WENO5, HLLC, RK3, exact incompressible initial field, serial CPU, GNU 13). Inner/outer wall-shear rms relative error (local cubic fits at 96 wall points) and torque ratio B/B_exact; analytic reference u = A r + B / r. "Before" is master, "after" this PR.

Regime A (annulus): Mach 0.01, Re 11.

cells/R options inner shear before after outer before after torque ratio before after
20 default 0.470 0.214 0.514 0.515 1.0259 1.0026
20 ib_wall_order = 2 0.381 0.0150 0.0374 0.0032 1.0119 0.99966
30 default 0.472 0.292 0.486 0.487 1.0041 0.9963
30 ib_wall_order = 2 0.359 0.0128 0.0188 0.0038 1.0019 0.99980

Regime A2 (same annulus geometry, second parameter set): Mach 0.05, Re 40.

cells/R options inner shear before after outer before after torque ratio before after
20 default 0.422 0.204 0.439 0.443 1.0218 1.0031
20 ib_wall_order = 2 0.357 0.0341 0.0343 0.0031 1.0148 0.99991
30 default 0.368 0.277 0.423 0.423 1.0015 0.9957
30 ib_wall_order = 2 0.284 0.0262 0.0091 0.0040 1.0009 0.99990

The outer (fixed) wall is unchanged by the fix, as expected. With the default (first-order) ghost the inner shear is still 20 to 29 % because that ghost is first order on a curved wall; the torque error at 30 cells/R changes sign with similar magnitude (+0.41 % to -0.37 %), so the default option set does not converge faster, it only removes the rotating-specific part. With ib_wall_order = 2 the inner shear drops 5 to 25 times and the torque is within 0.01 to 0.04 % at both grids and in both regimes. Combined with ib_ip_interp = 2 and ib_visc_compact = T at 20 cells/R (Regime A) the inner shear is 0.0065 and the outer 0.0016.

Regime B (different geometry, no outer IB ring): a circle of radius R spinning at Omega in a square box of half-width 3R with no-slip domain-boundary walls (bc = -16), gas initially the Couette field of R_o = 3R, Mach 0.05, Re = Omega R^2 / nu = 1, run to t = 30 (the torque still drifts by about 0.04 % per tenth of the run, so it is steady to that level), GNU 13 CPU, serial. The square box has no closed-form solution. The annulus value for R_o = 3R, T = 4 pi mu Omega R^2 R_o^2/(R_o^2 - R^2) = 3.534e-2, and the unbounded 2D value without the box correction, 3.142e-2, bracket it, so they are bounds only. The reference used is the numerical torque of this PR with ib_wall_order = 2 at 40 cells/R (3.504e-2, equivalent annulus R_o = 3.15R, inside the bracket). Its uncertainty is not tight: the same option set gives 3.491, 3.492, 3.493, 3.504 (e-2) at 16, 24, 32, 40 cells/R, a 0.35 % spread, so errors below about 0.3 % are not resolved. Error columns are relative to that reference; u(r = 1.1R) is the azimuthal-mean u_theta from a local linear fit, compared with the reference run at the same radius.

cells/R options torque error before after u(1.1R) error before after
16 default -4.3 % -2.7 % -4.5 % -2.8 %
16 ib_wall_order = 2 -2.9 % -0.35 % -3.0 % +0.2 %
24 default -4.3 % -2.6 % -3.8 % -2.2 %
24 ib_wall_order = 2 -2.6 % -0.33 % -2.2 % +0.1 %
32 default -2.6 % -1.6 % -2.3 % -1.3 %
32 ib_wall_order = 2 -1.7 % -0.29 % -1.4 % +0.1 %
40 default -2.3 % -1.2 % -2.5 % -1.3 %
40 ib_wall_order = 2 -1.3 % reference -1.4 % reference

The wall-speed defect shows as a torque and near-wall velocity deficit of the same size at every resolution that the fix removes; before the fix the second-order option converges to the reference only at first order (-2.9, -2.6, -1.7, -1.3 %), after it the torque is flat to 0.35 %. The first-order default is still 1 to 3 % low, as in the annulus.

3D sphere (the same box setup in 3D, fd_order = 2): a sphere of radius R spinning at Omega = 0.1 in a cubic box of half-width 2.5R with no-slip walls, Mach 0.1, Re = 1, started from rest, t = 20 (torque drift below 0.05 % per tenth of the run except 0.4 % in the base 16 cells/R run), serial GNU 13 CPU. The unbounded Stokes torque 8 pi mu Omega R^3 = 0.2513 is a lower bound for any enclosed box; the sphere-in-sphere value with R_o = 2.5R, 0.2685, is an upper bound for this cube, and the volume-equivalent sphere (R_o = 3.1R) gives about 0.260. Torque magnitude (Mach 0.1 adds an O(M^2) of about 1 %):

cells/R default before after ib_wall_order = 2 before after
8 0.2340 0.2426 0.2507 0.2610
12 0.2384 0.2458 0.2522 0.2615
16 not run not run 0.2558 0.2631

With the fix and ib_wall_order = 2 the torque lies inside the bracket 0.2513 to 0.2685 at every resolution and near the volume-equivalent estimate (0.260; +0.4 to +1.2 %). Before the fix it is at or just below the unbounded-Stokes lower bound (0.2507 at 8, 0.2522 at 12, 0.2558 at 16 cells/R) and creeps upward with resolution. The default (first-order) ghost stays below the lower bound even with the fix (0.2426, 0.2458 against 0.2513; before 0.2340, 0.2384), as in 2D. This is a bracketing check, not an analytic one.

Translation plus spin. Direct probe of the ghost-velocity routine (scratch build with a print, not in the PR): a circle with U = 0.05 along x, Omega = 0.05 (R = 1) in a periodic box with the gas at U, 24 cells/R, first RK stages, 8100 ghost points. The wall point is exactly on the circle (|r_w| - R below 3e-16). The imposed velocity minus U + Omega x (R r_hat) is 1.6e-17 at most with the fix (roundoff). Before the fix the error was Omega |levelset|, up to 8.8e-3 (mean 4.0e-3), i.e. 18 % of the spin speed at the deepest ghost point and 8 % on average (the ghost layer reaches up to 0.18R inside). Galilean check: the final torque (t = 15, still developing from rest) of the same body with U = 0.05 and gas at U, relative to U = 0 (the same physical problem): -5.8 % before, -3.3 % after with the default ghost; -3.3 % before, -0.2 % after with ib_wall_order = 2; the lateral force on the U = 0.05 body is -4.5e-4 before and -2.3e-5 after (ib_wall_order = 2), against an exact zero at U = 0. The remainder is the discretisation error of a body and flow crossing the grid, not roundoff: this is not bitwise Galilean invariance, only a large improvement.

Tests, what was compared. ./mfc.sh test --generate was run on master and on this branch (GNU 13 double CPU, no MPI, --no-examples) for the IBM label (117 tests) and the master and branch goldens were compared byte for byte; they differ only in the tests listed below (two more, 09FDDC81 and 6DE4C39D, differ at roundoff, 2e-14 and 4e-29 of the field scale, and pass at the test tolerance). The whole non-example suite (794 tests) was also regenerated on the branch and compared with the committed goldens: apart from the listed tests all differ at machine roundoff only (below 1e-10 of the field scale, which is the platform noise between the original generators and this one). That first regeneration did not cover the example tests or the multi-rank (MPI) variants; CI found three more changed goldens there (the Example tests rotating_sphere and tumbling_rectangle, and the 2-rank sibling of the force-driven AMR case), which were regenerated afterwards on a GNU 12.3 + OpenMPI 4.1.5 CPU MPI build (Georgia Tech Phoenix) and re-run to pass. The three remaining failures on the Phoenix OpenMP lanes (MPI Consistency -> 3D -> Bubbles, two Reactive Shocktube AMR 2-rank chemistry cases) are "Failed to execute MFC" on tests with no immersed body.

Goldens regenerated (max |change| relative to the largest golden value, master vs this PR). The prescribed-rotation tests, including the two examples, move by 1e-3 to 4e-2; the others are two-way coupled bodies that spin up under torque, so only the rotational part of the wall velocity moves.

test UUID change
2D IBM Translating Spinning Circle, Body-Frame Force 540C72F1 3.8e-2
2D IBM Rotating Circle 5C04A681 5.1e-3
3D IBM Prescribed Kinematics Pitch Ramp (1 fluid) D7E7DE04 1.0e-3
3D IBM Prescribed Kinematics Pitch Ramp (2 fluids) 5334FF40 1.0e-3
AMR 2D static IBM circle spinning 7CA4FC48 8.5e-4
3D IBM Wall Collision Sliding Friction 9C037B27 9.6e-8
2D Hypoelasticity HLLD IBM Two-way Circle BA59123E 2.7e-8
2D IBM Moving Circle Two-way CFL restart B7A370B8 2.8e-9
AMR 2D moving IBM circle force-driven 952F1CEF 2.3e-10
AMR 2D moving IBM circle force-driven, 2 MPI ranks 60F620F8 7.6e-10
Example 2D tumbling_rectangle (omega = 100) 87C3F801 4.5e-3
Example 3D rotating_sphere (omega = 100) 6076815B 2.3e-3

Translation is unaffected: Translating Circle is bitwise unchanged while Translating Spinning Circle (same case with angular_vel = 3) moves by 3.8e-2, and the wall velocity is the sum translation + omega x r_w by f_wall_velocity.

The first 9 goldens plus Static Circle With Angular Velocity, Translating Circle and Adaptive dt (one of them roundoff-level changed, the others unchanged) pass on NVIDIA A100 80GB (Georgia Tech wingtip), NVHPC 25.5 OpenACC, against the regenerated goldens (the 2 AMR cases in a second run); the change is arithmetic and agrees with the CPU build. golden-metadata.txt is committed as generated.

Not verified: a tight analytic reference for the boxed spinning cylinder (the reference is numerical, uncertain to about 0.3 %; the box cases above are no-slip box walls and a periodic box only), higher-Re or compressible spin (Mach 0.05 only), AMR beyond the two golden cases, moving plus deforming bodies, CCE/AMD (CI lanes), more than 2 ranks. Boxed cases above 40 cells/R were not obtained: at 48 and 64 cells/R every variant, with and without this PR, produced NaN at a box corner when the first pressure wave reached the walls (a no-slip domain-corner issue unrelated to this change, not investigated).

Type of change

  • Bug fix

Testing

./mfc.sh precheck; goldens regenerated and compared as above; Couette tables above on GNU 13 CPU.

This PR was made with Claude Code (AI).

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: 9e158cf

Files changed:

  • 1
  • src/simulation/m_ibm.fpp

Findings:
No issues found. Checked in step 4: src/simulation/m_ibm.fpp (f_wall_point, s_compute_ghost_point_pressure, s_compute_ghost_point_velocity). Note: the prepared context directory was empty, so I read the file from the working tree (master) alongside the diff.

@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_ibm.fpp 3865 +7
Directory Lines Diff
simulation 41167 +7
total 61237 +7

@sbryngelson

Copy link
Copy Markdown
Member Author

CI (full suite, Coverage lane) found three changed goldens that my first regeneration missed because it skipped the example tests and the multi-rank variants: rotating_sphere (6076815B), tumbling_rectangle (87C3F801) and the 2-rank force-driven AMR case (60F620F8). All three involve a rotating or tumbling body and move by 2.3e-3, 4.5e-3 and 7.6e-10 of the field scale. They are regenerated in 1f8bfda on a GNU 12.3 + OpenMPI 4.1.5 CPU MPI build (Georgia Tech Phoenix) and re-run to pass. The PR description is corrected: the earlier "byte for byte" and "roundoff only" statements covered the IBM label and the non-example, single-rank suite only. I also added a 3D sphere torque bracket check to the description. Three other failures on the Phoenix OpenMP lanes (MPI Consistency -> 3D -> Bubbles, two 2-rank Reactive Shocktube AMR cases) are "Failed to execute MFC" on tests with no immersed body and are not touched by this change.

This comment was made with Claude Code (AI).

@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.14%. Comparing base (4264341) to head (1f8bfda).
⚠️ Report is 32 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2383      +/-   ##
==========================================
+ Coverage   65.72%   66.14%   +0.42%     
==========================================
  Files         111      112       +1     
  Lines       30549    31096     +547     
  Branches     4673     4749      +76     
==========================================
+ Hits        20079    20570     +491     
+ Misses       6699     6675      -24     
- Partials     3771     3851      +80     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson
sbryngelson merged commit 13b4d8b into MFlowCode:master Nov 23, 2026
51 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant